package com.jeecg.p3.divination.service.impl;

import com.jeecg.p3.divination.dao.WxActDivinationShareDao;
import com.jeecg.p3.divination.entity.WxActDivinationShare;
import com.jeecg.p3.divination.service.WxActDivinationShareService;
import org.jeecgframework.p3.core.utils.common.PageList;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.utils.common.PageQueryWrapper;
import org.jeecgframework.p3.core.utils.common.Pagenation;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述：</b>摇签分享表<br>
 * @author：weijian.zhang
 * @since：2018年03月13日 13时56分52秒 星期二 
 * @version:1.0
 */
@Service("wxActDivinationShareService")
public class WxActDivinationShareServiceImpl implements WxActDivinationShareService {
	@Resource
	private WxActDivinationShareDao wxActDivinationShareDao;

	@Override
	public void doAdd(WxActDivinationShare wxActDivinationShare) {
		wxActDivinationShareDao.insert(wxActDivinationShare);
	}

	@Override
	public void doEdit(WxActDivinationShare wxActDivinationShare) {
		wxActDivinationShareDao.update(wxActDivinationShare);
	}

	@Override
	public void doDelete(String id) {
		wxActDivinationShareDao.delete(id);
	}

	@Override
	public WxActDivinationShare queryById(String id) {
		WxActDivinationShare wxActDivinationShare  = wxActDivinationShareDao.get(id);
		return wxActDivinationShare;
	}

	@Override
	public PageList<WxActDivinationShare> queryPageList(
		PageQuery<WxActDivinationShare> pageQuery) {
		PageList<WxActDivinationShare> result = new PageList<WxActDivinationShare>();
		Integer itemCount = wxActDivinationShareDao.count(pageQuery);
		PageQueryWrapper<WxActDivinationShare> wrapper = new PageQueryWrapper<>(pageQuery.getPageNo(), pageQuery.getPageSize(),itemCount, pageQuery.getQuery());
		List<WxActDivinationShare> list = wxActDivinationShareDao.queryPageList(wrapper);
		Pagenation pagenation = new Pagenation(pageQuery.getPageNo(), itemCount, pageQuery.getPageSize());
		result.setPagenation(pagenation);
		result.setValues(list);
		return result;
	}

	//根据时间来查询分享记录
	@Override
	public WxActDivinationShare queryOneByDate(String actId, String openid, String format) {
		return wxActDivinationShareDao.queryOneByDate(actId,openid,format);
	}
	
}
